/**
 * Created by thomas on 2017/12/2.
 */
'use strict';

var gulp = require('gulp');
var sass = require('gulp-sass');
var connect = require('gulp-connect');//livereload
var minifyCss = require("gulp-minify-css");
var proxy = require('http-proxy-middleware');

gulp.task('sass', function () {
    return gulp.src('./sass/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(minifyCss().on("error",function(e){
            console.log(e);
        }))
        .pipe(gulp.dest('./static/css'));
});


gulp.task('sass:watch', function () {
    gulp.watch('./sass/**/*.scss', ['sass',"html"]);
});

gulp.task('connect',function(){
    connect.server({
        root: '',
        port: 8011,
        livereload: true,
    });
});

gulp.task('watch', function () {
    gulp.watch(['./*.html'], ['sass','html']);
});

gulp.task('html', function () {
    gulp.src('./*.html')
      .pipe(connect.reload());
  });

gulp.task('default',["connect","sass:watch","watch"]);